package Controllayer;
import Modellayer.*;
import java.util.*;
import DBlayer.*;

/**
 *
 * @author bruhn
 */
public class ProductCtr {
    
    public ProductCtr()
    {
    }

     public ArrayList findAllProduct()
        {
        IFDBProduct dbProduct = new DBProduct();
        ArrayList allProduct = new ArrayList();
        allProduct = dbProduct.getAllProduct(false);
        return allProduct;
        }

        public Product findProduct(int ID, boolean retriveAssociation)
	{
		IFDBProduct dbProduct = new DBProduct();
                return dbProduct.findProduct(ID, true);
	}


	public int updateProduct(int ID, String name, double purchasePrice, double salesPrice, double rentPrice, String countryOfOrigin, int minStock, int maxStock, int currentStock, String type)
      {
          IFDBProduct dbProduct = new DBProduct();
          Product prod = new Product();
          prod.setName(name);
          prod.setPurchasePrice(purchasePrice);
          prod.setSalesPrice(salesPrice);
          prod.setRentPrice(rentPrice);
          prod.setCountryOfOrigin(countryOfOrigin);
          prod.setMinStock(minStock);
          prod.setMaxStock(maxStock);
          prod.setCurrentStock(currentStock);
          prod.setType(type);
		  prod.setProductID(ID);
          return  dbProduct.updateProduct(prod);
      }

        public void insertNew(Product prodObj)
      {
           IFDBProduct dbProduct = new DBProduct();
           dbProduct.insertProduct(prodObj);
      }


        public void deleteProduct(int ID)
	{
            IFDBProduct dbProduct = new DBProduct();
            dbProduct.deleteProduct(ID);
	}
		public Supplier findSupplier(int ID)
	{
		IFDBSupplier dbSupplier = new DBSupplier();
        return dbSupplier.findSupplier(ID);
	}
}
